# -*- coding: utf-8 -*-
import urllib
import sys
import Cookie
import logging

from gluon.tools import fetch

class groupAgent:
    def __init__(self):
        '''
        Log in with GAE urlfetch
        '''
        self.cookie = Cookie.SimpleCookie()
        loginurl = 'http://www.douban.com/login'
        loginParams = {'form_email':'qvnachi@gmail.com',
                       'form_password':'821216',
                       'user_login': '进入',
                       'remember': True,
                }
        self.response = fetch(url=loginurl,
                              data=loginParams,
                              cookie=self.cookie)
        
    def getGroupPage(self, id='Sweden'):
        logging.info('Start fetching http://www.douban.com/group/%s/members' % id)
        return fetch(url='http://www.douban.com/group/%s/members' % id,
                     cookie=self.cookie)